<?php
/**
 *  ==============================================================
 *  Created by PhpStorm.
 *  User: Ice
 *  邮箱: ice@sbing.vip
 *  网址: https://sbing.vip
 *  Date: 2020/7/9 上午9:44
 *  ==============================================================
 */

namespace addons\error500;

use addons\error500\library\ErrorHandle;
use fast\Http;
use think\Addons;
use think\exception\HttpException;
use think\exception\HttpResponseException;

/**
 * 错误页面插件
 */
class Error500 extends Addons
{

    /**
     * 插件安装方法
     *
     * @return bool
     */
    public function install()
    {
        return true;
    }

    /**
     * 插件卸载方法
     *
     * @return bool
     */
    public function uninstall()
    {
        return true;
    }

    public function appExceptionReport($e)
    {
        try {
            ErrorHandle::throwReportEmail($e['exception'], $e['ignoreReport']);
        } catch (\Exception $e) {

        }
    }

    public function adminExceptionReport(\Throwable $e)
    {
        try {
            ErrorHandle::throwReportEmail($e['exception'], $e['ignoreReport']);
        } catch (\Exception $e) {

        }
    }

    public function adminException(\Throwable $e)
    {
        ErrorHandle::throw500($e);
    }

    public function appException(\Throwable $e)
    {
        ErrorHandle::throw500($e);
    }
}
